﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.WebPages;

namespace MVC.Web.UI.Panel
{
    public class WebPanel : MvcControl
    {
        #region Fields
        private HtmlHelper _htmlHelper; 
        #endregion

        #region Constructors
        public WebPanel(ViewContext context)
            : base("div", context)
        {
            
        } 
        #endregion

        #region Properties

        public HelperResult Content { get; set; }

        public string Title { get; set; }

        #endregion

        protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
        {
            /*
             *<div id="Panel">
             *       <h3>Title</h3>
             *       <div>
             *             <div style="width:400px; height:200px;">Content</div> 
             *       </div>
             * </div> 
             */
                //Render Header    
                writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.H3);
                writer.InnerWriter.Write(this.Title);
                writer.RenderEndTag(); //End A
                
                // Render Content
                writer.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
                if (this.Content != null)
                    this.Content.WriteTo(writer);
                writer.RenderEndTag();// div 
        }

        protected override void RenderScripts(System.Web.UI.HtmlTextWriter writer)
        {
            writer.Write(this.Scripts);      
        }
    }
}
 